GetPlaylistByName [C#]
[C#]
//Get list of playlist for specific group and specific manager filtered by name public ErrorType GetPlaylistByName(out List<View_Playlist> filteredList, List<long> listGroupId, string filter, string login = "", string password = "") { //Initialize the return value(s) ErrorType result = ErrorType.CONNECTION_ERROR; filteredList = new List<View_Playlist>(); //Check user connection if ((manager != null && sessionId != "" && login == "" && password == "") //Already connected || "ok" == GetSessionId(out sessionId, out manager, login, password)) //Get Manager connection data { //Get list of playlist for specific group and specific manager List<View_Playlist> listResult; result = client.GetPlaylist(out listResult, listGroupId, manager.Id, sessionId); if (result == ErrorType.GOOD) { //Filter the result with linq filteredList = (from l1 in listResult where l1.Name.Contains(filter) select l1).ToList(); //For filter by id //filteredList = (from l1 in listResult where l1.Id == Id select l1).ToList(); } } return result; } //Get list of playlist component for specific playlist public ErrorType GetPlaylistMedia(out List<View_PlaylistComponent> listResult, long groupId, long playlistId, string login = "", string password = "") { //Initialize the return value(s) ErrorType result = ErrorType.CONNECTION_ERROR; listResult = new List<View_PlaylistComponent>(); //Check user connection if ((manager != null && sessionId != "" && login == "" && password == "") //Already connected || "ok" == GetSessionId(out sessionId, out manager, login, password)) //Get Manager connection data { //Get list of playlist component for specific playlist result = client.GetPlaylistComponent(out listResult, playlistId, groupId, manager.Id, sessionId); } return result; } //Add playlist component for specific playlist public ErrorType AddPlaylistMedia(ref View_PlaylistComponent component, long groupId, string login = "", string password = "") { //Initialize the return value(s) ErrorType result = ErrorType.CONNECTION_ERROR; //Check user connection if ((manager != null && sessionId != "" && login == "" && password == "") //Already connected || "ok" == GetSessionId(out sessionId, out manager, login, password)) //Get Manager connection data { //Add media to playlist result = client.AddPlaylistComponent(ref component, groupId, null, manager.Id, sessionId); } return result; } //Get list of xml medias for specific group public ErrorType GetXMLMedia(out List<XMLMedia> listResult, long groupId, string login = "", string password = "") { //Initialize the return value(s) ErrorType result = ErrorType.CONNECTION_ERROR; listResult = new List<XMLMedia>(); //Check user connection if ((manager != null && sessionId != "" && login == "" && password == "") //Already connected || "ok" == GetSessionId(out sessionId, out manager, login, password)) //Get Manager connection data { //Get list of xml medias for specific group result = client.GetXMLMedia(out listResult, groupId, manager.Id, sessionId); } return result; }
[C#]
//Check login and retrive connection session private string GetSessionId(out string sessionId, out View_Manager manager, string login = "", string password = "") { //Encrypt the password string passswordEncrypt = GetPasswordEncrypt(password, GlobalParam.SERVER_KEY); //Check login and retrive connection session long serverDate; ErrorType result = client.CheckLoginSDK(out sessionId, out manager, out serverDate, login, passswordEncrypt); return GetErrorBySessionId(sessionId, manager, result); }
[C#]
//Get error result by session id private static string GetErrorBySessionId(string sessionId, View_Manager manager, ErrorType result) { if (result == ErrorType.GOOD) { //Result Error switch (sessionId) { case "0": return "Wrong login or password"; case "-1": return "Account Expired"; case "-2": return "Connection not allowed"; case "-3": return "Server error"; case "-4": return "Error, Please try again"; case "-5": return "Error, Please try again"; case "-6": return "Connection not allowed"; case "-7": return "Installation not completed"; } if (manager != null) { return "ok"; } } else { switch (result) { case ErrorType.CONNECTION_ERROR: return "Connection error"; case ErrorType.DISCONNECTED: return "Manager disconnected"; case ErrorType.MANAGEREXIST: return "Can not create manager because this name as already used"; case ErrorType.NOT_POSSIBLE: return "This action is not possible"; case ErrorType.PLAYERINGROUP: return "Can not delete this group because one or more player have in this group"; } } return "General error"; }
[C#]
//Get encryption key private byte[] GetHashKey(string hashKey) { // Initialise UTF8Encoding encoder = new UTF8Encoding(); // Get the salt string salt = "fCycS3qSKsUlNz7wCb39XckN"; byte[] saltBytes = encoder.GetBytes(salt); // Setup the hasher Rfc2898DeriveBytes rfc = new Rfc2898DeriveBytes(hashKey, saltBytes); // Return the key return rfc.GetBytes(16); }
[C#]
//Encrypt data by AES private string Encrypt(byte[] key, string dataToEncrypt) { // Initialise AesManaged encryptor = new AesManaged(); // Set the key encryptor.Key = key; encryptor.IV = key; // create a memory stream using (MemoryStream encryptionStream = new MemoryStream()) { // Create the crypto stream using (CryptoStream encrypt = new CryptoStream(encryptionStream, encryptor.CreateEncryptor(), CryptoStreamMode.Write)) { // Encrypt byte[] utfD1 = UTF8Encoding.UTF8.GetBytes(dataToEncrypt); encrypt.Write(utfD1, 0, utfD1.Length); encrypt.FlushFinalBlock(); encrypt.Close(); // Return the encrypted data return Convert.ToBase64String(encryptionStream.ToArray()); } } }